package client.ClientTools;
/*
工具类
包含DateUtil方法获取当前时间
 */

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;

public class DateUtil {
    public String getCurentDate() {
        LocalDateTime date = LocalDateTime.now();
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        String NowTime = date.format(dtf);
        return NowTime;
    }
    /*public String getCurentDate(){
        String currentTime = null;

        Calendar calendar = Calendar.getInstance();

        //时
        String hour = String.valueOf(calendar.get(Calendar.HOUR));
        if(Calendar.HOUR > 10){
            hour = '0'+hour;
        }
        //分
        String minute = String.valueOf(calendar.get(Calendar.MINUTE));
        if(Calendar.MINUTE<10){
            minute = '0'+minute;
        }
        //秒
        String second = String.valueOf(calendar.get(Calendar.SECOND));
        if(Calendar.SECOND<10){
            second = '0'+second;
        }
        currentTime =hour+":"+minute+":"+second;

        return currentTime;
    }*/
}
